package eggcatcher;

import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.util.ArrayList;

public class Basket implements MouseMotionListener, MouseListener  {
	private int pos_x;
	private int pos_y;
	private ArrayList<Egg> EggsList;
	private ArrayList<Shit> ShitsList;
	private Point origin;
	private Point mousePt;
	Basket(int posX, int posY) {
		pos_x = posX;
		pos_y = posY;
		EggsList = new ArrayList<Egg>();
		ShitsList = new ArrayList<Shit>();
		origin = new Point(posX, posY);
	}
	
	public int getPosX() {
		return pos_x;
	}
	public void setPosX(int x) {
		pos_x=x;
	}
	public int getPosY() {
		return pos_y;
	}
	public void setPosY(int y) {
		pos_y=y;
	}
	public void moveLeft() {
		pos_x-=10;
	}
	public void moveRight() {
		pos_x+=10;
	}
	public void addEgg(Egg e) {
		EggsList.add(e);
	}
	public void addShit(Shit s) {
		ShitsList.add(s);
	}
	public ArrayList<Egg> getEggsList() {
		return EggsList;
	}
	public ArrayList<Shit> getShitsList() {
		return ShitsList;
	}

	@Override
	public void mouseDragged(MouseEvent e) {
		int dx = e.getX() - mousePt.x;
        //int dy = e.getY() - mousePt.y;
        origin.setLocation(origin.x + dx, origin.y);
        mousePt = e.getPoint();
        if (origin.getX()<20) origin.setLocation(20, origin.y);
        if (origin.getX()>430) origin.setLocation(430, origin.y);

        this.setPosX((int) origin.getX());
        this.setPosY((int) origin.getY());
		//System.out.println("mouse dragged" + origin.getX()+","+origin.getY());
        
	}

	@Override
	public void mouseMoved(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		mousePt = e.getPoint();		
		//System.out.println("mouse pressed" + mousePt.getX()+","+mousePt.getY());
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	
}
